package com.dairy.escape;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

/**
 * All rights Reserved, Designed By https://gitee.com/es-cape/escape.git
 *
 * @ProjectName: 
 * @Package: 
 * @ClassName: Write
 * @Description: $[description]
 * <p> </p>
 * @Author: escape
 * @Date: 2022/5/24
 * @Version: 
 **/
@Slf4j
public class Write {
    public static void File_write() throws IOException {




            Date date = new Date();

            DateFormat format = new SimpleDateFormat("yyyy-MM-dd");

            String str = format.format(date);
            File file = new File("E://date/"+File1.name+"---"+File1.title+"---"+str+File1.weather+".txt" );
            if (!file.exists()) {
                try {
                    file.createNewFile();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                log.info("文件已创建");
            } else {
                log.info("文件已存在,已追加内容");
            }
            System.out.println("输入内容");
            try
            {
                Scanner sc = new Scanner(System.in);
                String content=sc.next();
                FileOutputStream out=new FileOutputStream(file,true);
                out.write(content.getBytes());

            }

            catch (FileNotFoundException e)
            {

                log.info("文件不存在或者文件不可读或者文件是目录");
            }
            catch (IOException e)
            {
                log.info("读取过程存在异常");
            }
                log.info("===========输入完成！=============");
                log.info("已经返回菜单！1，写日记    2.读取日记");


        }
}
